//
//  LTLPhotoView.m
//  WeiBo
//
//  Created by LiTaiLiang on 16/9/30.
//  Copyright © 2016年 LTL. All rights reserved.
//
#import "LTLPhotoView.h"
#import "LTLPhone.h"
@interface LTLPhotoView ()

@property(nonatomic,strong) UIImageView *LTLimage;

@end

@implementation LTLPhotoView
/**
 *  懒加载
 *
 *  @param photo GIF
 */
-(UIImageView *)LTLimage
{
    if (_LTLimage == nil) {
        _LTLimage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"timeline_image_gif"]];
        
        [self addSubview:_LTLimage];
    }
    return _LTLimage;
}
#pragma mark - 数据处理
-(void)setPhoto:(LTLPhone *)photo
{
    _photo = photo;
    [self sd_setImageWithURL:[NSURL URLWithString:_photo.thumbnail_pic] placeholderImage:[UIImage imageNamed:@"timeline_image_placeholder"]];
 //判断是否是CIF图片
    if ([photo.thumbnail_pic hasSuffix:@"gif"]) {
        //
        self.LTLimage.hidden = NO;
    }
    else
    {
        self.LTLimage.hidden = YES;
    }
}
//设置认证类型
-(void)setVerifiedType:(LTLverifiedType)verifiedType
{
    _verifiedType = verifiedType;
    self.hidden = NO;
    //判断类型
    switch (_verifiedType) {
        case LTLverifiedTypeNoAuthentication:
            self.hidden = YES;
            break;
        case LTverifiedTypeLcelebrity :
            self.image = [UIImage imageNamed:@"avatar_vip"];
            break;
        case LTLverifiedTypegovernment:
        case LTLverifiedTypeenterprise:
        case LTLverifiedTypemedia:
        case LTLverifiedTypeCampus:
        case LTLverifiedTypewebsite:
            self.image = [UIImage imageNamed:@"avatar_enterprise_vip"];
            break;
        default:
            break;
    }
}
-(void)layoutSubviews
{   //photo为空说明是认证类型
    if (self.photo != nil) {
        self.LTLimage.x = self.width-_LTLimage.width;
        self.LTLimage.y = self.width-_LTLimage.highly;
    }
}
@end
